package com.javawork.igossip;

import com.javawork.igossip.R;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class LoginActivity extends Activity {

	EditText txtName, txtPas;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_login);
		txtName = (EditText) findViewById(R.id.txtName);
		txtPas = (EditText) findViewById(R.id.txtPass);
		txtName.setText(UserManager.User.username);
		txtPas.setText(UserManager.User.password);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.login, menu);
		return true;
	}

	public void btn_login_click(View v) {
		// Toast.makeText(this, "haha", 1).show();
		UserManager.User.username = txtName.getText().toString();
		UserManager.User.password = txtPas.getText().toString();
		LocalStorageHelper.updateUserInfo(UserManager.User);
		UserManager.isLoggedIn = true;
		Intent intent = new Intent(LoginActivity.this, MainActivity.class);
		startActivity(intent);
		this.finish();
	}

}
